package com.hmall.order.task;

import com.hmall.order.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author sjqn
 */
@Component
@Slf4j
public class orderTask {

    /**
     * 定时任务 每隔60秒触发一次
     */
    @Autowired
    private IOrderService orderService;
    @Scheduled(cron = "0/60 * * * * ?")
    public void orderTask(){
        log.info("开始检查超时未支付订单...");
        orderService.cancelTimeoutOrders();
        log.info("超时订单检查完成");
    }
}